Consider a curve given by the function $f(x)$ on the interval $[0,1]$ with the property $f(0)=f(1)=0$ and $f(x) > 0$ everywhere else. The length of the curve is $l \le 0$. What curve will have the maximum area under the function?

We want to maximize the area functional: $$ S[f] = \int_0^1 f(x) d x $$ subject to the constraint $$ A[f] = \int_0^1 \sqrt{1+f'(x)^2} dx = l $$ So we must extremize the modified functional: $$ \tilde S[f, \lambda] = \int_0^1 \left(f(x)+\lambda \sqrt{1+f'(x)^2}\right) d x $$ The Euler-Lagrange equations $$ {\delta \tilde S\over\delta f(x)} - {d\over d x} {\delta \tilde S\over\delta f'(x)} = 0 $$ become $$ 1-{d\over d x}\left(\lambda {f'(x)\over \sqrt{1+f'(x)^2}}\right) = 0 $$ Integrating: $$ x-\lambda {f'(x)\over \sqrt{1+f'(x)^2}} = c_1 $$


In [30]:
import sympy.interactive
sympy.interactive.init_printing()

Let's assume $c_1 = 0$ for now...


In [53]:
from sympy import var, Symbol, Function, sqrt, solve, integrate, simplify, refine, Q, python, Derivative, Abs, Id, powsimp
var("x c1")
lam = Symbol("lambda")
f = Function("f")
L = f(x) + lam*sqrt(1 + f(x).diff(x)**2)
eq0 = L.diff(f(x)) - Derivative(L.diff(f(x).diff(x)), x)
eq0


Out[53]:
$$- \frac{\partial}{\partial x}\left(\frac{\lambda \frac{\partial}{\partial x} \operatorname{f}{\left (x \right )}}{\sqrt{\left(\frac{\partial}{\partial x} \operatorname{f}{\left (x \right )}\right)^{2} + 1}}\right) + 1$$

In [54]:
# integrate can't handle it directly (it will work in the next release)
# eq = integrate(eq0, x)
eq = x - lam * f(x).diff(x) / sqrt(1+f(x).diff(x)**2) #- c1
eq


Out[54]:
$$- \frac{\lambda \frac{\partial}{\partial x} \operatorname{f}{\left (x \right )}}{\sqrt{\left(\frac{\partial}{\partial x} \operatorname{f}{\left (x \right )}\right)^{2} + 1}} + x$$

In [55]:
sqrt(f(x)).diff(f(x))


Out[55]:
$$\frac{1}{2 \sqrt{\operatorname{f}{\left (x \right )}}}$$

In [56]:
dfx = solve(eq, f(x).diff(x))[1]
dfx


Out[56]:
$$\sqrt{\frac{x^{2}}{\lambda^{2} - x^{2}}}$$

In [57]:
fx = integrate(dfx, x)
fx


Out[57]:
$$- \frac{\lambda^{2} \sqrt{x^{2}} \sqrt{\frac{1}{\lambda^{2} - x^{2}}}}{x} + x \sqrt{x^{2}} \sqrt{\frac{1}{\lambda^{2} - x^{2}}}$$

In [58]:
fx = simplify(fx)
fx


Out[58]:
$$\frac{\left(- \lambda^{2} + x^{2}\right) \sqrt{x^{2}} \sqrt{\frac{1}{\lambda^{2} - x^{2}}}}{x}$$

In [59]:
fx = refine(fx, Q.positive(x))
fx


Out[59]:
$$\left(- \lambda^{2} + x^{2}\right) \sqrt{\frac{1}{\lambda^{2} - x^{2}}}$$

In [60]:
refine(fx, Q.positive(lam**2-x**2))   # Unfortunately does not work...


Out[60]:
$$\frac{- \lambda^{2} + x^{2}}{\sqrt{\lvert{\lambda^{2} - x^{2}}\rvert}}$$

In [61]:
-refine(simplify(-fx), Q.positive(lam**2-x**2))


Out[61]:
$$- \frac{\lambda^{2} - x^{2}}{\sqrt{\lvert{\lambda^{2} - x^{2}}\rvert}}$$

So the solution is $f(x) = -\sqrt{\lambda^2 - x^2}$. The minus sign should not be there, it probably got in at some point...


In [ ]: